package com.abcdefg.springioc;
//
//import com.abcdefg.springioc.demo4.Demo2;
import com.abcdefg.springioc.demo5.Demo1;
import com.abcdefg.springioc.demo6.Demo2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
public class SpringIocApplication {

    public static void main(String[] args) {
//获取Spring上下文对象
        ConfigurableApplicationContext context =
                SpringApplication.run(SpringIocApplication.class, args);
        Demo2 bean = context.getBean(Demo2.class);
        bean.demo2();
//        Demo1 bean = context.getBean(Demo1.class);
//        bean.demo1();
//        Demo2 bean = context.getBean(Demo2.class);
//        bean.demo2();
//        Demo2 bean = context.getBean(Demo2.class);
//        bean.demo2();
//        User bean =(User) context.getBean("hahh");
//        System.out.println(bean);
//        //从Spring上下文获取Bean对象
//        ControllerDemo bean = context.getBean(ControllerDemo.class);
//        bean.controllerMethod();
//
//        ControllerDemo bean1 = (ControllerDemo)context.getBean("controllerDemo");
//        bean1.controllerMethod();
//
//        ControllerDemo bean2 = context.getBean("controllerDemo", ControllerDemo.class);
//        bean2.controllerMethod();
//
//        HElloController bean3 = (HElloController)context.getBean("HElloController");
//        bean3.controllerMethod2();
//        ServiceDemo bean =(ServiceDemo) context.getBean("serviceDemo");
//        bean.ServiceMethod();
//        RepositoryDemo bean2 =(RepositoryDemo) context.getBean("repositoryDemo");
//        bean2.RepositoryMethod();
//        ComponentDemo bean1 = context.getBean(ComponentDemo.class);
//        bean1.ComponentMethod();
//        ConfigurationDemo bean3 = context.getBean(ConfigurationDemo.class);
//        bean3.ConfigurationMethod();


    }
}
